//


#import "AM_TabBarViewController.h"
#import "AM_SettingViewController.h"
#import "AM_MainViewController.h"




@interface AM_TabBarViewController ()



@property (nonatomic, strong) UINavigationController * nav1;
@property (nonatomic, strong) UINavigationController * nav2;

@end

@implementation AM_TabBarViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createTabBarweewewView];//创建
    [self createSubviddssdsdewControllers];//
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabHidden) name:@"Hidden" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabAppear) name:@"show" object:nil];//观
    
}
//隐藏tabbar
- (void)tabHidden{
    self.tabBarView.hidden = YES;
}
//显示tabbar
- (void)tabAppear{
    self.tabBarView.hidden = NO;
}

//创建标签栏
- (void)createTabBarweewewView{
    self.tabBar.hidden = YES;

    NSArray * imagesNormal = @[@"home1", @"setting1"];
    NSArray * imagesSelected = @[@"home2", @"setting2"];
    NSArray * buttonTitle = @[@"Home", @"Setting"];
    
    __weak typeof(self) weakself=self;
    NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:imagesNormal,@"imageNameNormal",imagesSelected,@"imageNameSelected",buttonTitle,@"buttonTitle", nil];
    self.tabBarView = [[AM_TabBarView alloc]initWithFrame:CGRectMake(0,kMainScreenHeight-UI_TAB_BAR_HEIGHT,kMainScreenWidth, UI_TAB_BAR_HEIGHT) andTabBarButtonParrkDictory:dic andBlock:^(NSInteger index) {
        weakself.selectedIndex = index;
    }];
    [self.view addSubview:self.tabBarView];
}

//构建子撒视图控制器
- (void)createSubviddssdsdewControllers{
    //创建子控完全制器
    AM_MainViewController *v1 = [[AM_MainViewController alloc] init];//
    AM_SettingViewController * v2 = [[AM_SettingViewController alloc] init];
    
    //创建子控sa制器的导e233的速度航栏控制器
    self.nav1 = [[UINavigationController alloc] initWithRootViewController: v1];
    self.nav2 = [[UINavigationController alloc] initWithRootViewController: v2];
    self.viewControllers =@[self.nav1,self.nav2];
    
}


@end
